/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.chlitina.store.common.config.Global;
import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.web.BaseController;
import com.chlitina.store.modules.expert.entity.ProductCategory;
import com.chlitina.store.modules.expert.service.ProductCategoryService;

/**
 * 产品分类Controller
 * @author lvbo
 * @version 2013-06-03
 */
@Controller
@RequestMapping(value = Global.ADMIN_PATH+"/expert/productCategory")
public class ProductCategoryController extends BaseController {
	@Autowired
	private ProductCategoryService productCategoryService;
	
	@ModelAttribute
	public ProductCategory get(@RequestParam(required=false) Long id) {
		if (id != null){
			return productCategoryService.get(id);
		}else{
			return new ProductCategory();
		}
	}
	
	@RequestMapping(value = {"list", ""})
	public String list(ProductCategory productCategory, HttpServletRequest request, HttpServletResponse response, Model model) {
		String searchName = request.getParameter("productCategoryName");
		Page<ProductCategory> page = productCategoryService.find(new Page<ProductCategory>(request, response), searchName); 
        model.addAttribute("page", page);
		return "modules/expert/productCategoryList";
	}
}
